﻿using Application.Dto;
using Application.IAppSrevices;
using AutoMapper;
using Domain.Entitys;
using Domain.Repositorys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.AppSrevices
{
    public class CFSKService : ICFSKService
    {
        private readonly ICFSKRepositoty cFSKRepositoty;
        private readonly IMapper mapper;

        public CFSKService(ICFSKRepositoty cFSKRepositoty,IMapper mapper)
        {
            this.cFSKRepositoty = cFSKRepositoty;
            this.mapper = mapper;
        }

        /// <summary>
        /// 删除2级结构表数据
        /// </summary>
        /// <param name="cFSK"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> CFSKDeleteAsync(CFSKDeleteDto cFSKDeleteDto)
        {
            CFSK cFSK1 = mapper.Map<CFSK>(cFSKDeleteDto);
            return await cFSKRepositoty.CFSKDeleteAsync(cFSK1);
        }

        /// <summary>
        /// 添加二级结构表数据
        /// </summary>
        /// <param name="cFSK"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> CFSKInsertAsync(CFSKAddDto cFSKAddDto)
        {
            CFSK cFSK = mapper.Map<CFSK>(cFSKAddDto);
            //Random random = new Random();
            //int randomPart = random.Next(10000, 100000);
            //long number = 2353318900000L + randomPart;
            //cFSK.SecondKindId = number.ToString();
            return cFSKRepositoty.CFSKInsertAsync(cFSK);
        }

        /// <summary>
        /// 根据2级编号查询对应数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<CFSK> CFSKSelectByCfkid(string id)
        {
            return await cFSKRepositoty.CFSKSelectByCfkid(id);
        }


        /// <summary>
        /// 根据id查询对应数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<CFSK> CFSKSelectById(int id)
        {
            return await cFSKRepositoty.CFSKSelectById(id);
        }


        /// <summary>
        /// 分页查询二级结构表数据
        /// </summary>
        /// <param name="fenYe"></param>
        /// <returns></returns>
        public FenYe<CFSK> CFSKSelectFenYe(FenYe<CFSK> fenYe)
        {
            return cFSKRepositoty.CFSKSelectFenYe(fenYe);
        }
        /// <summary>
        /// 根据1级结构编号查询数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<CFSK>> CFSKSelectid(string id)
        {
            return await cFSKRepositoty.CFSKSelectid(id);
        }

        /// <summary>
        /// 查询2级结构表数据并作为下拉框
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<List<CFSK>> CFSKSelectOption()
        {
            return cFSKRepositoty.CFSKSelectOption();
        }

        /// <summary>
        /// 修改2级结构表数据
        /// </summary>
        /// <param name="cFSK"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> CFSKUpdateAsync(CFSK cFSK)
        {
            return cFSKRepositoty.CFSKUpdateAsync(cFSK);
        }
    }
}
